package com.example.blog.mapper;

import com.example.blog.model.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserInfoMapper {
    // 根据用户名查询用户信息
    @Select("select id, user_name, password, github_url, delete_flag, create_time, update_time " +
            "from user where delete_flag = 0 and user_name = #{userName}")
    UserInfo selectUserInfoByName(String userName);

    // 根据用户 id 查询用户信息
    @Select("select id, user_name, password, github_url, delete_flag, create_time, update_time " +
            "from user where delete_flag = 0 and id = #{id}")
    UserInfo selectUserInfoById(Integer id);

    @Update("update user set password = #{password} where id = #{id}")
    Integer updatePassword(String password, Integer id);
}
